
<?php


$con = mysql_connect('localhost', 'root', '');
if (!$con) {
	die('Could not connect: '.mysql_error());
}

mysql_select_db("aris", $con);
mysql_query("SET NAMES UTF8");
$sql = "SELECT * FROM machine";

$result = mysql_query($sql);
$numrow = mysql_num_rows($result);
$Divrow = $numrow / 3;
$Modrow = $numrow % 3;
$Divrow=number_format(($Divrow),0,'.',''); 
if(($numrow % 3)==1) $Divrow++;
$countCol = 3;
$countSQL=0;
echo "  <table  id='box-table-Mac'>  ";
for ($i=0;$i<$Divrow ;$i++ ) {
echo "<tr>";
	for ($j=0;$j<3 ;$j++ ) {
	 $txt="<td class='thumbnail' style=\"cursor:pointer;\" onclick=\"$('#cheMac".$countSQL."').prop('checked',$('#cheMac".$countSQL."').is(':checked')? false:true);\"> ";
	if($countSQL<$numrow){
		if (mysql_result($result, $countSQL, "status") == 1) //=1 กำลังใช้
				echo "<td class='thumbnail'  style='background-color:#FEF7EC;'><input disabled  type='checkbox' name='choidMac[]' value='";
			else
				//echo $txt."<input  type='checkbox' name='choidMac[]' value='";
				echo $txt."<input id='cheMac".$countSQL."' type='checkbox' name='choidMac[]' value='";
	//echo "<input type='checkbox' name='choidMac[]' value='";
	echo mysql_result($result, $countSQL, "id");
	echo "'>";
	echo mysql_result($result, $countSQL, "name");
	echo "<span><img src='";
	echo mysql_result($result, $countSQL, "img");
	echo "'/><br />";
	echo mysql_result($result, $countSQL, "name");
	echo "</span>";
	}
		else echo $txt;
	$countSQL++;
	echo "</td>";
	}
echo "</tr>";
}

echo "</table>  ";
//echo "<table border=1>  ";
//while ($row = mysql_fetch_array($result)) {
//	if ($countCol  == 1) {
//		echo"<tr>";
//		
//	}else if($countCol  == 3){
//	 echo "</tr>";
//	}
//	echo "<td>";
//	echo   $row['id'];
//	echo "</td>";
//	if (($countCol / 3) == 1) {
//		echo "<tr>";
//		$countCol=1;
//	}else{
//	$countCol++;
//	}
//}
//echo "</table>  ";
mysql_close($con);
?>

<script>
//alert("<?php echo $Divrow ?>");



</script>